package com.shanjupay.merchant;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;
import java.util.List;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients //开启feign服务
public class MerchantApplicationBootstrap2104 {
    public static void main(String[] args) {
        SpringApplication.run(MerchantApplicationBootstrap2104.class, args);
    }

    @Bean
    public RestTemplate restTemplate(){
        //默认的jdk依赖  用的是okhttp3
        RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory());
        //转换器列表
        List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters();
        //配置转换器 并配置编码格式  utf-8  默认的是ISO-8859-1
        list.set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
        return restTemplate;
    }

}
